package com.bonc.rms.jpa;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.bonc.rms.entity.UserEntity;

public interface UserRepository extends JpaRepository<UserEntity, Integer>{


	public List<UserEntity> findAll();
	
	public UserEntity findOne(Integer id);
	
	public List<UserEntity> findByDepartment(String department);
	
	public List<UserEntity> findByUserName(String user_name);
	
	public UserEntity findUserEntityByUserName(String user_name);
		
	public List<UserEntity> findByUserNameAndDepartment(String user_name, String department);
	
	public UserEntity save(UserEntity user);	
	
	public void delete(Integer id);
	
	@Modifying
	@Query("Update UserEntity u set u.state = ?1 where u.id = ?2")
	public void updateStateById(String state, Integer id);
	
	@Query("select passwd from UserEntity  where userName = ?1")
	public String findPasswdByUserName(String userName);
	
	@Query("select userName from UserEntity u ")
	public List<String> findAllUserName();
	
	@Query("select userName from UserEntity where userName = ?1")
	public String isExistUserName(String userName);
	

}
